<include file="Public:head" title="源码列表"/>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <include file="Public:left" />
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="__APP__/{$Think.MODULE_NAME}">首页</a></li>
                    <li><a href="{:U('Source/lists')}">源码管理</a></li>
                    <li class="active">源码列表</li>
                </ul>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="header smaller lighter blue">
                                    <div class="nav-search col-xs-12" id="nav-search">
                                        <form class="form-search" method="get">
                                               <div class="search_left" style="float:left">
                                                   当前有{$count_not}个源码未分配，<button class="btn btn-info btn-sm" type="button" onclick="assign_source()">
                                                        <i class="bigger-110 "></i>
                                                        获 取
                                                    </button>
                                                   </div>
                                            <div class="search_area">
                                                <input class="form-control search-query" type="text" name="points" id="points" autocomplete="off"  placeholder="火币小" value="{$Think.get.points}">
                                                  <input class="form-control search-query" type="text" name="points2" id="points2" autocomplete="off"  placeholder="火币大" value="{$Think.get.points2}">
                                                 <select name="is_download" autocomplete="off">
                                                    <option value="">请选择是否下载</option>
                                                    <option value="-1" <if condition="$is_download eq -1 && $is_download neq ''">selected</if>>否</option>
                                                    <option value="0" <if condition="$is_download eq 0 && $is_download neq ''">selected</if>>是</option>
                                                </select>
                                                <select name="is_check" autocomplete="off">
                                                    <option value="">请选择是否开启</option>
                                                    <option value="0" <if condition="$is_check eq 0 && $is_check neq ''">selected</if>>否</option>
                                                    <option value="1" <if condition="$is_check eq 1">selected</if>>是</option>
                                                </select>
                                                <select name="is_show" autocomplete="off">
                                                    <option value="">请选择是否显示</option>
                                                      <option value="0" <if condition="$is_show eq 0 && $is_show neq ''">selected</if>>否</option>
                                                    <option value="1" <if condition="$is_show eq 1">selected</if>>是</option>
                                                </select>
<!--                                                <select name="is_complete" autocomplete="off">
                                                    <option value="">请选择是否通过</option>
                                                    <option value="-1" <if condition="$is_complete eq -1">selected</if>>未完成未通过</option>
                                                    <option value="1" <if condition="$is_complete eq 1">selected</if>>完成未审核</option>
                                                    <option value="2" <if condition="$is_complete eq 2">selected</if>>完成已通过</option>
                                                </select>-->
                                                   <input type='hidden' name='p' value='0'>
                                                <input class="form-control search-query" type="text" name="keyword" autocomplete="off"  placeholder="请输入源码名称" value="{$Think.get.keyword}">
                                                <button class="btn btn-purple btn-sm" type="submit">搜 索 <i class="icon_search icon-on-right bigger-110"></i></button>
                                            </div>
                                        </form>
                                    </div>
                                    <div class='cl'></div>
                                </div>
                                <notempty name='lists'>
                                    <div class="table-responsive">
                                        <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                            <thead>
                                                <tr>
                                                    <th class="center" width='45px'>
                                                        <label>
                                                            <input type="checkbox" class="ace"  autocomplete="off"/>
                                                            <span class="lbl"></span>
                                                        </label>
                                                    </th>
                                                    <th width='45px' class="center">ID</th>

                                                    <th>源码名称</th>
                                                    <th>源码分类</th>
                                                    <th>源码行业</th>
                                                    <th style="width:320px">源码来源</th>
                                             
                                                    <th width="75px">浏览次数</th>
                                                    <th width="75px">下载次数</th>
                                                    <if condition="$s_admin_uid eq 1">
                                                    <th width="75px">是否下载</th>
                                                    <th width="75px">是否开启</th>
                                                    <th width="75px">是否显示</th>
                                                    </if>
                                                    <th width="113px"><i class="icon-time bigger-110 hidden-480"></i>添加时间</th>
                                                      <th width="113px"><i class="icon-time bigger-110 hidden-480"></i>完成时间</th>
                                                    <th width="115px">操作</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                            <foreach name="lists" item="row">
                                                <tr>

                                                    <td class="center">
                                                        <label><input type="checkbox" class="ace" name="ids" value="{$row.id}" autocomplete="off" /><span class="lbl"></span></label>
                                                    </td>
                                                    <td class="center">{$row.id}<if condition="$s_admin_uid eq 1">（{$row.uid}）</if></td>
                                                    <td  id="name_{$row.id}"><a href="http://www.sucaihuo.com/source/{$row['id']}.html" target="_blank">{$row.name|msubstr=0,32,'utf-8',true}</a></td>
                                                    <td>{$row.cat_id|getSingleField=###=###,'source_dictionary','name'}</td>
                                                    <td>{$row.color_id|getImplode=###,'source_dictionary'}</td>
      
<!--                                                    <td id="source_{$row.id}"><a onclick="changeOrd($(this), 'source', '{$row.id}', 'source')"><if condition="$row.source eq ''">0<else/>{$row.source}</if></a><a href="{$row.source}" style='margin:0 0 0 10px' target="_blank"><strong class="red">{$row.points}</strong></a></td>-->
                                                
                                                                            <td id="source_{$row.id}"><if condition="$row.source eq ''">0<else/><p  style="width:320px;">{$row.source}</p></if></a><a href="{$row.source}" style='margin:0 0 0 10px' target="_blank"><strong class="red">{$row.points}</strong></td>

                                                       
                                               
                                                  
                                                <td><a onclick="changeOrd($(this), 'source', '{$row.id}', 'times_view')">{$row.times_view}</a></td>
                                                <td><a onclick="changeOrd($(this), 'source', '{$row.id}', 'times_download')">{$row.times_download}</a></td>
                                                <if condition="$s_admin_uid eq 1">
                                                <td id="is_download_{$row.id}"><a onclick="no_download('{$row.id}', 'source', 'is_download')"><if condition="$row.is_download eq 0 && $row['is_download'] neq ''">是<else/><span style="color:red">否</span></if></a></td>
                                                <td id="is_check_{$row.id}"><a onclick="yes('{$row.id}', 'source', 'is_check')"><if condition="$row.is_check eq 1">是<else/><span style="color:red">否</span></if></a></td>
                                                <td id="is_show_{$row.id}"><a onclick="yes('{$row.id}', 'source', 'is_show')"><if condition="$row.is_show eq 1">是<else/><span style="color:red">否</span></if></a></td> 
                                               </if>
                                                <td>{$row.addtime|date="Y-m-d H:i",###}</td>
                                                  <td><if condition="$row.time_create gt 0">{$row.time_create|date="Y-m-d H:i",###}<else/>请检查<span class="red">{$row.not_complete}</span></if></td>
                                                <td class="action-buttons">
<!--                                                    <a class="purple" data-rel="tooltip" data-original-title="演示地址" href="http://www.sucaihuo.com/source/{$row['id']}.html" target="_blank"><i class="icon-facetime-video bigger-130"></i></a>-->
                                                    <a class="green" href="{:U('Source/detail',array('id'=>$row['id']))}" data-rel="tooltip" data-original-title="编辑"><i class="icon-pencil bigger-130"></i></a>
               <a class="purple" onclick="update_cache('{$row.id}',15)">更新缓存</a>
                                                </td> 
                                                </tr>
                                            </foreach>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div id="grid-pager" class="ui-state-default  ui-corner-bottom" dir="ltr">
                                        <table width='100%' data-table='source'  id='modal_del_table'>
                                            <tr>
                                                <td>
                                                    <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
<!--                                                        <a class="red" data-toggle="modal" onclick="targetDelTable(0)"  data-rel="tooltip" data-original-title="批量删除">
                                                            <i class="icon-trash bigger-130"></i>
                                                        </a>-->
<!--                                                                <a class="yellow" onclick="start_source(0)">批量开启</a>-->
<!--                                                           <a class="blue" onclick="show_source(0)">批量显示</a>
                                                        <a class="red" onclick="push_source(0)">批量推送</a>-->

                                                    </div>
                                                </td>
                                                <td class='td_pager'><div class='pager'>{$page}</div></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <else/>
                                    <p class='noempty'>没有符合条件的记录！</p>
                                </notempty>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <include file="Public:setting" />
    </div>
</div>
<include file="Public:del" />
<include file="Public:state" />
<include file="Public:foot" />

<script>
    function push_source(id) {
        var ids = '';
        if (id == 0) {

            $("input[name='ids']").each(function() {
                if ($(this).prop("checked") == true) {
                    ids += $(this).val() + ",";
                }
            });

        } else {
            ids = id;
        }
        if (ids == '') {
            alert("请选择！");
            return false;
        }
        $.post(getUrl('Ajax/push_source'), {ids: ids}, function(data) {
            alert(data);
        }, "json")
    }
     function start_source(id) {
        var ids = '';
        if (id == 0) {

            $("input[name='ids']").each(function() {
                if ($(this).prop("checked") == true) {
                    ids += $(this).val() + ",";
                }
            });

        } else {
            ids = id;
        }
        if (ids == '') {
            alert("请选择！");
            return false;
        }
        $.post(getUrl('Ajax/start_source'), {ids: ids}, function(data) {
            alert(data);
        }, "json")
    }
        function show_source(id) {
        var ids = '';
        if (id == 0) {

            $("input[name='ids']").each(function() {
                if ($(this).prop("checked") == true) {
                    ids += $(this).val() + ",";
                }
            });

        } else {
            ids = id;
        }
        if (ids == '') {
            alert("请选择！");
            return false;
        }
        $.post(getUrl('Ajax/show_source'), {ids: ids}, function(data) {
            alert(data);
        }, "json")
    }
    function assign_source() {
//        $.post(getUrl('Ajax/update_uid2'), {ids: 1}, function(data) {
//            if(data == -1){
//                alert('您暂无权限更新');
//                return false;
//            }else if(data == 0){
//                alert('暂无id');
//                return false;
//            }else{
//                  alert(data);
//            location.reload();
//            }
//          
//        })
        $.post(getUrl('Ajax/clear_source'), {ids: 1}, function(data) {
            if(data>0){
                assign_source()
            }
          
        })
    }

</script>